aboutsummaryrefslogtreecommitdiff
path: root/src/pages/blog/[id].astro
blob: 50bf9984a927bd142126e5347f30848838221a49 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
---
import type { GetStaticPaths } from "astro";
import Layout from "../../layouts/Layout.astro";
import { getCollection, render } from "astro:content";

export const getStaticPaths = (async () => {
	const entries = await getCollection("blog");
	return entries.map((entry) => ({
		params: { id: entry.id },
		props: { entry },
	}));
}) satisfies GetStaticPaths;

const { entry } = Astro.props;
const { Content } = await render(entry);
const formattedDate = new Date(entry.data.publishedAt).toLocaleDateString(
	"es-ES",
	{
		year: "numeric",
		month: "long",
		day: "numeric",
		weekday: "long",
	},
);

const schema = {
	"@context": "https://schema.org",
	"@type": "BlogPosting",
	headline: entry.data.title,
	datePublished: entry.data.publishedAt.toISOString(),
	author: {
		"@type": "Person",
		name: "Ariel Costas Guerrero",
	},
	publisher: {
		"@type": "Person",
		name: "Ariel Costas Guerrero",
		logo: {
			"@type": "ImageObject",
			url: "https://www.costas.dev/favicon.png",
		},
	},
};
---

<Layout title={entry.data.title} description={entry.data.metaDescription}>
	<script is:inline type="application/ld+json" slot="head-jsonld" set:html={JSON.stringify(schema)}></script>

	<h1>{entry.data.title}</h1>
	<small>
		Publicado el
		<time datetime={entry.data.publishedAt.toISOString()}>
			{formattedDate}
		</time>
	</small>

	<Content />
</Layout>